package containers

func InsertSort(arr *[]int) {
	for i := 0; i < len(*arr); i++ {
		for pre := i - 1; pre >= 0 && (*arr)[pre] > (*arr)[pre+1]; pre-- {
			(*arr)[pre], (*arr)[pre+1] = (*arr)[pre+1], (*arr)[pre]
		}
	}
}

func InsertSort2(arr *[]int) {
	for i := 0; i < len(*arr); i++ {
		m := (*arr)[i]
		pre := i - 1
		for ; pre >= 0 && (*arr)[pre] > m; pre-- {
			(*arr)[pre+1] = (*arr)[pre]
		}
		(*arr)[pre+1] = m
	}
}
func InsertSort3(arr *[]int, l, r int) {
	for i := l; i <= r; i++ {
		m := (*arr)[i]
		pre := i - 1
		for ; pre >= l && (*arr)[pre] > m; pre-- {
			(*arr)[pre+1] = (*arr)[pre]
		}
		(*arr)[pre+1] = m
	}
}
